<html>
<script>
var handler = {
    get: function(target, name) {

    	console.log("proxy handler called, context: " + target + " proxy name: " + name);
    	for( var pr in target){
    		console.log("property: " + pr + " native? " + target.hasOwnProperty(pr));
    	}
        return name in target ?
            target[name]:
            37;
    }
};
/*
var p = new Proxy({ac: "Jerry"}, handler);
p.a = 1;
p.b = undefined;

console.log(p.a, p.b); // 1, undefined
console.log('c' in p, p.c); // false, 37
*/

console.log("test employee");
function Employee(name){
	this.name = name;
};

Employee.prototype.work = function(language){
	console.log(this.name + " is developing with: " + language);
}

let jerry = new Employee("Jerry");

function hireEmployee(employee, language){
    employee.work(language);
}

hireEmployee(jerry, "JavaScript");

var proxyLogic = {
    get: function(target, name) {
    	if( name == "work"){
    		var oriFun = target[name].bind(target);
    		return function(language){
    			oriFun(language);
    			console.log("and also study other language in spare time");
    		}
    	}
    }
};

var jerryProxy = new Proxy(jerry, proxyLogic );

hireEmployee(jerryProxy, "JavaScript");

</script>
</html>